package ai.people.platform.archives.service.impl;

import ai.people.netmon.framework.domain.archives.vo.InformationDataBasicFieldVO;
import ai.people.platform.archives.mapper.InformationScoreDetailsMapper;
import ai.people.platform.archives.service.InformationScoreDetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ai.people.netmon.framework.domain.archives.entity.InformationScoreDetails;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author ligua
* @description 针对表【information_score_details(积分明细表)】的数据库操作Service实现
* @createDate 2022-06-06 16:11:38
*/
@Service
public class InformationScoreDetailsServiceImpl extends ServiceImpl<InformationScoreDetailsMapper, InformationScoreDetails>
    implements InformationScoreDetailsService {

    @Resource
    private InformationScoreDetailsMapper informationScoreDetailsMapper;

    /**
     * 检查是否已查看
     *
     * @param userId   用户id
     * @param dataList 数据列表
     * @return {@link List}<{@link InformationScoreDetails}>
     */
    @Override
    public List<InformationScoreDetails> checkHasViewed(Long userId, List<InformationDataBasicFieldVO> dataList) {
        if(userId != null && CollectionUtils.isNotEmpty(dataList)){
            return informationScoreDetailsMapper.selectListByUserIdAndDataList(userId,dataList);
        }
        return Lists.newArrayList();
    }

    /**
     * 获取已消费积分
     *
     * @param userId 用户id
     * @return {@link Long}
     */
    @Override
    public Long getSpeedScore(Long userId) {
        if(userId == null){
            return 0L;
        }
        return informationScoreDetailsMapper.selectSpeedScoreSum(userId);
    }
}




